define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            $(".btn-add").data('area',["100%",'100%']);
            $(".btn-edit").data('area',["100%",'100%']);
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'sales/slip/index' + location.search,
                    add_url: 'sales/slip/add',
                    edit_url: 'sales/slip/edit',
                    del_url: 'sales/slip/del',
                    multi_url: 'sales/slip/multi',
                    table: 'sales_slip',
                }
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                dblClickToEdit: false,
                sortName: 'id',
                rowStyle:function(row, index){
                    if (row.ystatus == 9) {
                        return{
                            css:{
                                color:'red'
                            }
                        }
                    }else{
                        return{}
                    }
                },
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'),class: 'sid'},

                        {field: 'number', title: __('Number'), formatter: Controller.api.formatter.number},
                        {field: 'ccompany', title: __('Nickname')},
                        {field: 'name', title: __('Name'),searchList: $.getJSON(Config.this_url+"/config/zaxconfig?states=1")},
                        // {field: 'status', title: __('Status')},
                        // {field: 'deliverytime', title: __('Deliverytime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},

                        // {field: 'abstract', title: __('Abstract')},
                        // {field: 'admin_id', title: __('Admin_id')},
                        // {field: 'group_id', title: __('Group_id')},
                        {field: 'sales_num', title: __('销售数量'),operate:false},
                        {
                            field: 'goods_name', title: __('商品名称'), visible: false
                        },
                        {
                            field: 'goods_number', title: __('商品编号'), visible: false
                        },
                        {field: 'actual_cost', title: __('订单金额'),operate:false},
                        {field: 'operator', title: __('Operator'), formatter:Table.api.formatter.search},
                        {field: 'company', title: __('Company')},
                        {field: 'status', title: __('Status'),searchList: $.getJSON(Config.this_url+"/config/zaxconfig?states=8")},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'explain', title: __('Explain'),operate:false,class: 'explain',cellStyle:function (value, row, index) {
                                return {
                                    css: {
                                        "min-width": "100px",
                                        "white-space": "nowrap",
                                        "text-overflow": "ellipsis",
                                        "overflow": "hidden",
                                        "max-width": "120px"
                                    }
                                }
                            }},
                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            buttons: [
                                {
                                    name: 'examine',
                                    title: __('销售单审核'),
                                    classname: 'btn btn-xs btn-danger  btn-click editstatus',
                                    icon: 'fa fa-random',
                                    // font-size:80,
                                    hidden:function(row){
                                        if(row.ystatus != 1){
                                            return true;
                                        }
                                    },
                                    click: function(data){
                                        var sid =$(this).parents('tr').find('.sid').html()
                                        var url = Config.this_url+'/sales/slip/detail?ids='+sid
                                        layer.open({
                                            type: 2, // 1-在content中写html代码， 2-在content中写src路径
                                            area: ['80%', '90%'],
                                            title: "销售单详情",
                                            content: url,
                                            // content: Config.this_url+'/purchase/requisition',
                                        })

                                    }},
                                {
                                    name: 'change',
                                    title: __('单据转换'),
                                    classname: 'btn btn-xs btn-warning btn-click editstatus',
                                    icon: 'fa fa-exchange',
                                    hidden:function(row){
                                        if(row.ystatus < 2 || row.ystatus > 3 ){
                                            return true;
                                        }
                                    },
                                    click: function(data){
                                        var sid =$(this).parents('tr').find('.sid').html()
                                        var url = Config.this_url+'/sales/slip/change?ids='+sid
                                        layer.open({
                                            type: 2, // 1-在content中写html代码， 2-在content中写src路径
                                            area: ['80%', '90%'],
                                            title: "直发单转换",
                                            content: url,
                                            // content: Config.this_url+'/purchase/requisition',
                                        })
                                        // layer.confirm('是否转为厂家直发单？', {
                                        //     btn: ['确定','取消'] //按钮
                                        // }, function(){
                                        //     var url = Config.this_url +'/sales/slip/change?ids='+sid
                                        //     $.post(url,{},function (res) {
                                        //         layer.msg(res.msg)
                                        //         if(res.code == 1){
                                        //             setTimeout(function () {
                                        //                 $('.fa-refresh').click()
                                        //             },1000)
                                        //         }
                                        //     })
                                        // })
                                    }},
                                {
                                    name: 'history',
                                    title: __('单据回退'),
                                    classname: 'btn btn-xs btn-danger btn-click history',
                                    icon: 'fa fa-history',
                                    hidden:function(row){
                                        if(row.ystatus != 2){
                                            return true;
                                        }
                                    },
                                    click: function(data){
                                        var sid =$(this).parents('tr').find('.sid').html()
                                        layer.confirm('是否回退订单状态？', {
                                            btn: ['确定','取消'] //按钮
                                        }, function(){
                                            var url = Config.this_url +'/sales/slip/history?ids='+sid
                                            $.post(url,{},function (res) {
                                                layer.msg(res.msg)
                                                if(res.code == 1){
                                                    setTimeout(function () {
                                                        $('.fa-refresh').click()
                                                    },1000)
                                                }
                                            })
                                        })
                                    }},
                                {
                                    name: 'checkout',
                                    title: __('出库'),
                                    classname: 'btn btn-xs btn-success btn-click editstatus',
                                    icon: 'fa fa-level-down',
                                    hidden:function(row){
                                        if(row.ystatus < 2 || row.ystatus >3){
                                            return true;
                                        }
                                    },
                                    click: function(data){
                                        var sid =$(this).parents('tr').find('.sid').html()
                                        var url = Config.this_url+'/sales/checkout/add?slip_id='+sid
                                        layer.open({
                                            type: 2, // 1-在content中写html代码， 2-在content中写src路径
                                            area: ['80%', '90%'],
                                            title: "出库单",
                                            content: url,
                                            // content: Config.this_url+'/purchase/requisition',
                                        })
                                    }},
                                {
                                    name: 'formal',
                                    title: __('转为正式单'),
                                    classname: 'btn btn-xs btn-danger  btn-click editstatus',
                                    icon: 'fa fa-random',
                                    // font-size:80,
                                    hidden:function(row){
                                        if(row.ystatus != 7){
                                            return true;
                                        }
                                    },
                                    click: function(data){

                                        // layer.confirm('转换订单检测？', {
                                        //     btn: ['确定','取消'] //按钮
                                        // }, function() {
                                            var sid = $(this).parents('tr').find('.sid').html()
                                            layer.confirm('是否转为正式单？', {
                                                btn: ['确定', '取消'] //按钮
                                            }, function () {
                                                var url = Config.this_url + '/sales/slip/rational?ids=' + sid
                                                $.post(url, {}, function (res) {
                                                    if(res.code == 0){
                                                        layer.msg(res.msg)
                                                        return false;
                                                    }
                                                    if (res.data == 2) {
                                                        var url = Config.this_url + '/sales/slip/formal?ids=' + sid
                                                        $.post(url, {}, function (res) {
                                                            layer.msg(res.msg)
                                                            if (res.code == 1) {
                                                                setTimeout(function () {
                                                                    $('.fa-refresh').click()
                                                                }, 1000)
                                                            }
                                                        })
                                                    }else{
                                                        layer.confirm('价格异常,是否转换？', {
                                                            btn: ['确定', '取消'] //按钮
                                                        }, function () {
                                                            var url = Config.this_url + '/sales/slip/formal?ids=' + sid
                                                            $.post(url, {}, function (res) {
                                                                layer.msg(res.msg)
                                                                if (res.code == 1) {
                                                                    setTimeout(function () {
                                                                        $('.fa-refresh').click()
                                                                    }, 1000)
                                                                }
                                                            })
                                                        })
                                                    }
                                                })
                                            })
                                        // })
                                        // var sid =$(this).parents('tr').find('.sid').html()
                                        // var url = Config.this_url+'/sales/slip/detail?ids='+sid
                                        // layer.open({
                                        //     type: 2, // 1-在content中写html代码， 2-在content中写src路径
                                        //     area: ['80%', '90%'],
                                        //     title: "销售单详情",
                                        //     content: url,
                                        //     // content: Config.this_url+'/purchase/requisition',
                                        // })

                                    }},
                                // {
                                //     name: 'endslip',
                                //     title: __('强制中止'),
                                //     classname: 'btn btn-xs btn-danger btn-click editstatus',
                                //     icon: 'fa fa-close',
                                //     hidden:function(row){
                                //         if(row.ystatus <= 1 || row.ystatus >=5){
                                //             return true;
                                //         }
                                //     },
                                //     click: function(data){
                                //         var sid =$(this).parents('tr').find('.sid').html()
                                //         layer.confirm('是否强制终止该单据？', {
                                //             btn: ['确定','取消'] //按钮
                                //         }, function(){
                                //             var url = Config.this_url+'/sales/slip/endslip?ids='+sid
                                //             $.post(url,{},function (res) {
                                //                 layer.msg(res.msg)
                                //                 if(res.code == 1){
                                //                     setTimeout(function () {
                                //                         $('.fa-refresh').click()
                                //                     },1000)
                                //                 }
                                //             })
                                //         })
                                //     }}
                            ],
                            events: Table.api.events.operate,
                            formatter: function (value, row, index) {
                                var that = $.extend({}, this);
                                var table = $(that.table).clone(true)
                                // $(table).data("operate-del", null); // 列表页面隐藏 .编辑operate-edit - 删除按钮operate-del
                                // console.log(row)
                                if(row['ystatus'] == 1  || row['ystatus'] == 7){
                                    if(row['is_edit'] == 0){
                                        $(table).data("operate-edit", null);
                                    }
                                    // $(table).data("operate-edit", null);// 列表页面隐藏 .编辑operate-edit - 删除按钮operate-del
                                }else{
                                    $(table).data("operate-edit", null);// 列表页面隐藏 .编辑operate-edit - 删除按钮operate-del
                                }
                                if(row['ystatus'] !=7){
                                    $(table).data("operate-del", null);
                                }
                                that.table = table;
                                return Table.api.formatter.operate.call(that, value, row, index);
                            }}
                    ]
                ]
            });

            //当表格数据加载完成时
            table.on('load-success.bs.table', function (e, data) {
                //这里可以获取从服务端获取的JSON数据
                console.log(data);
                //这里我们手动设置底部的值
                // $("#num").text(data.num);
                // $("#price").text(data.price);
                $('#getcount').click()
            });
            $('#myTabContent').on('click','.btn-order',function(){
                var url = Config.this_url+'/sales/slip/syncorder'
                layer.open({
                    type: 2, // 1-在content中写html代码， 2-在content中写src路径
                    area: ['80%', '90%'],
                    title: "商城订单",
                    content: url,
                    // content: Config.this_url+'/purchase/requisition',
                })
            })
            $('#myTabContent').on('click','.btn-gather',function(){
                var url = Config.this_url+'/sales/slip/gather'
                layer.open({
                    type: 2, // 1-在content中写html代码， 2-在content中写src路径
                    area: ['70%', '80%'],
                    title: "查询",
                    content: url,
                    // content: Config.this_url+'/purchase/requisition',
                })
            })
            $('.commonsearch-table').on('click','.btn-success',function () {
                $('#getcount').click()
            })

            $('#getcount').click(function () {
                var data = $('form').serialize();
                that = $(this)
                var url = Config.this_url+'/sales/slip/getcount';
                $.post(url,data,function (res) {
                    that.find('#num').html(res.num)
                    that.find('#price').html(res.price)
                })
                setTimeout(function(){
                    layer.closeAll('loading');
                }, 2000);
            })
            $('table').on('dblclick','td',function(){

                // if($(this).parents('tr').find('.btn-editone').length >0){
                //     return  false;
                // }

                var sid = $(this).parents('tr').find('.sid').html()
                var url = Config.this_url+'/sales/slip/detail?ids='+sid
                layer.open({
                    type: 2, // 1-在content中写html代码， 2-在content中写src路径
                    area: ['100%', '100%'],
                    title: "销售单详情",
                    content: url,
                    maxmin:true
                    // content: Config.this_url+'/purchase/requisition',
                })
            });
            table.on('post-body.bs.table',function () {
                $(".btn-editone").data('area',["100%",'100%']);
            })
            $('body').on('mouseenter','.explain',function () {
                if (this.offsetWidth < this.scrollWidth) {
                    var that = this;
                    var text = $(this).text();
                    layer.tips(text, that,{
                        tips: 1,
                        time: 2000         //设置显示时间
                    });
                }
            })
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            $(".btn-add").click(function () {
                if($('#c-storehouse_id').val()== 0 ){
                    layer.msg('未选中出库仓库')
                    return false;
                }
                layer.open({
                    type: 2, // 1-在content中写html代码， 2-在content中写src路径
                    area: ['70%', '90%'],
                    title: "选择商品",
                    content: 'seach?house_id='+$('#c-storehouse_id').val(),
                })
            })
            var customer_id = 0;
            $(document).on("change", "#c-customer_id", function () {
                var cid = $('#c-customer_id').val()
                if(cid == ''){
                    return  false;
                }
                if(cid == customer_id){
                    return false;
                }
                customer_id = cid;
                var url = Config.this_url+'/customer/customer/detail?ids='+cid
                $.post(url,{},function (res) {
                    $('#default_mobile').val(res.mobile)
                    $('#default_address').val(res.address)
                    $('#default_contacts').val(res.nickname)
                    $('.symoney').html(res.symoney)
                })
            })
            Controller.api.bindevent();
        },
        gather: function () {
            $('.btn-embossed').click(function () {
                var turl = Config.this_url+'/sales/slip/gatherres?number='+$('.number').val()+'&storehouse_id='+$('#c-storehouse_id').val()+'&customer_id='+$('.customer_id').val()+'&starttime='+$('.start_time').val()+'&endtime='+$('.end_time').val();
                // console.log(turl)
                Backend.api.addtabs(turl, '汇总查询', 'fa fa-circle-o fa-fw');
            })
            $('.screen').click(function () {
                layer.open({
                    type: 2, // 1-在content中写html代码， 2-在content中写src路径
                    area: ['70%', '90%'],
                    title: "选择商品",
                    content: 'seach?house_id='+$('#c-storehouse_id').val(),
                })
            })
            Controller.api.bindevent();
        },
        change: function () {
            $('.btSelectAll').click(function (){
                var isChecked = $(this).is(':checked');
                $('.connnn').find("tr").each(function(){
                    $(this).find('input').prop('checked', isChecked);
                })
            })
            Controller.api.bindevent();
        },
        edit: function () {
            // $(".btn-add").click(function () {
            //     layer.open({
            //         type: 2, // 1-在content中写html代码， 2-在content中写src路径
            //         area: ['70%', '90%'],
            //         title: "选择商品",
            //         content: Config.this_url+'/sales/slip/seach',
            //     })
            // })
            $(".btn-add").click(function () {

                if($('#c-storehouse_id').val()== 0 ){
                    layer.msg('未选中出库仓库')
                    return false;
                }
                layer.open({
                    type: 2, // 1-在content中写html代码， 2-在content中写src路径
                    area: ['70%', '90%'],
                    title: "选择商品",
                    content: Config.this_url+'/sales/slip/seach?house_id='+$('#c-storehouse_id').val(),
                })
            })
            var customer_id = 0;
            $(document).on("change", "#c-customer_id", function () {
                var cid = $('#c-customer_id').val()
                if(cid == ''){
                    return  false;
                }
                if(cid == customer_id){
                    return false;
                }
                customer_id = cid;
                var url = Config.this_url+'/customer/customer/detail?ids='+cid
                $.post(url,{},function (res) {
                    $('#default_mobile').val(res.mobile)
                    $('#default_address').val(res.address)
                    $('#default_contacts').val(res.nickname)
                })
            })
            Controller.api.bindevent();
        },
        detail:function(){
            $('.cancelbill').click(function () {
                var url =  Config.this_url+'/sales/slip/cancelbill'+location.search
                layer.prompt({title: '输入红冲原因', formType: 2}, function(pass, index){
                    if(pass == ''){
                        layer.msg('不能为空');
                        return false;
                    }
                    $.post(url,{reason:pass},function (res) {
                        layer.msg(res.msg)
                        if(res.code == 1){
                            layer.close(index);
                            setTimeout(function () {
                                location.reload();
                            }, 800);
                            window.parent.$(".toolbar .btn-refresh").trigger('click');
                        }
                    })
                });
            })


            $('.btn-end').click(function () {
                    var ids = $(this).data('id');
                    layer.confirm('是否中止该商品？', {
                        btn: ['确定','取消'] //按钮
                    }, function(){
                        var url = Config.this_url +'/sales/slip/stop?ids='+ids
                        $.post(url,{},function (res) {
                            layer.msg(res.msg)
                            if(res.code == 1){
                                setInterval(function () {
                                    window.location.reload()
                                },1000)
                            }
                        })
                    })
            })
            $('.change').click(function () {
                    layer.confirm('转换订单检测？', {
                        btn: ['确定','取消'] //按钮
                    }, function() {
                        var url = Config.this_url + '/sales/slip/?ids=' + ids
                        // $.post(url, {}, function (res) {
                        //         layer.alert('该订单无法通过自动审核')
                        //         layer.confirm('是否转为正式单？', {
                        //             btn: ['确定', '取消'] //按钮
                        //         }, function () {
                        //             console.log(location.search)
                        //             var url = Config.this_url + '/sales/slip/?ids=' + ids
                        //             $.post(url, {}, function (res) {
                        //                 layer.msg(res.msg)
                        //                 if (res.code == 1) {
                        //                     setInterval(function () {
                        //                         window.location.reload()
                        //                     }, 1000)
                        //                 }
                        //             })
                        //         })
                        //
                        // })
                    })
            })
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            },
            formatter: {
                number: function (value, row, index) {
                    // alert(2)
                    //这里手动构造URL
                    // url = "discuss?" + this.field + "=" + value;
                    //询问框

                    // layer.confirm('搜索直发单还是出库单？', {
                    //     btn: ['直发单','出库单'] //按钮
                    // }, function(){
                    //     url = "actory/sales?sl_number=" + value;
                    //     return '<a href="' + url + '" class="label label-success addtabsit" title="' + __("Search %s", value) + '">' + __( value) + '</a>';
                    //
                    // }, function(){
                        url = "sales/checkout?slip.number=" + value;
                    //     return '<a href="' + url + '" class="label label-success addtabsit" title="' + __("Search %s", value) + '">' + __( value) + '</a>';
                    //
                    // });

                    return '<a href="' + url + '" class="label label-success addtabsit" title="' + __("Search %s", value) + '">' + __( value) + '</a>';

                    //方式一,直接返回class带有addtabsit的链接,这可以方便自定义显示内容

                    //方式二,直接调用Table.api.formatter.addtabs
                    // return Table.api.formatter.addtabs(value, row, index, url);
                }
            }
        },
        seach:function(){
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'goods/goods/specs',
                    table: '',
                }
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'weigh',
                pageSize:15,
                // searchFormVisible: true,
                searchFormTemplate: 'customformtpl',
                columns: [
                    [
                        // {checkbox: true,operate:false},
                        {field: 'id', title: 'ID', operate: false,class:'sid'},
                        {field: 'number', title: __('number'),sortable:true},
                        {field: 'title', title: __('title'),  operate: false,sortable:true},
                        // {field: 'place_origin', title: __('place_origin'), formatter: Table.api.formatter.search},

                        // {field: 'unit', title: __('unit'), align: 'left'},
                        {field: 'specs', title: __('specs')},
                        {field: 'stock', title: __('stock'),sortable:true},
                        {field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            buttons: [
                                {
                                    name: 'returnorder',
                                    title: __('选中'),
                                    classname: 'btn btn-xs btn-success btn-click editstatus',
                                    icon: 'fa fa-fighter-jet',
                                    hidden:function(row){
                                        // if(row.status != '审核'){
                                        //     return true;
                                        // }
                                    },
                                    click: function(data){
                                        var sid =$(this).parents('tr').find('.sid').html()
                                        $(this).attr('style','display:none')
                                        parent.getrequisition(sid);
                                        // console.log(parent.getrequisition(sid))
                                        // console.log('返回结果:'+res)
                                    }}
                            ],
                            events: Table.api.events.operate,
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            });
            $('table').on('dblclick','td',function(){
                var sid =$(this).parents('tr').find('.sid').html()
                parent.getrequisition(sid);
                var index = parent.Layer.getFrameIndex(window.name);
                parent.Layer.close(index);
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        gatherres:function(){
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'sales/slip/gatherres' + location.search,
                    table: 'sales_slip',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                pageSize:15,
                searchFormVisible: true,
                searchFormTemplate: 'customformtpl',
                // commonSearch: false,
                visible: false,
                showToggle: false,
                // showColumns: false,
                search:false,
                // showExport: false,
                columns: [
                    [
                        {checkbox: true,operate:false},
                        {field: 'id', title: 'ID', operate: false, formatter: function (value, row, index) {
                             return '<span class="sid" data-id="'+row.sales_slip_id+'" data-url="'+row.controller+'">'+value+'</span>';
                        }},
                        {field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: false, datetimeFormat:"YYYY-MM-DD"},
                        {field: 'number', title: __('number')},
                        {field: 'company', title: __('company'),  operate: false},


                        // {field: 'type', title: __('type')},
                        {field: 'title', title: __('title')},
                        {field: 'gnumber', title: __('商品编号')},
                        {field: 'specs', title: __('specs')},
                        {field: 'name', title: __('品牌')},

                        {field: 'goods_num', title: __('销售数量')},
                        {field: 'sale_price', title: __('单价')},
                        {field: 'ht_price', title: __('含税单价')},
                        {field: 'goods_price', title: __('订单金额')},
                        {field: 'sfhj', title: __('税费合计')},
                        // {field: 'deliver_price', title: __('发货金额')},
                        {field: 'operator', title: __('operator')},
                        // {field: 'name', title: __('所属仓库')},
                        {field: 'explain', title: __('explain')},
                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            buttons: [

                            ],
                            events: Table.api.events.operate,
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            });
            $('table').on('dblclick','td',function(){
                var sales_slip_id = $(this).parents('tr').find('.sid').data('id')
                // var turl = $(this).parents('tr').find('.sid').data('url')
                // var url = Config.this_url+'/'+turl+'?ids='+source_id
                var url = Config.this_url+'/sales/slip/detail?ids='+sales_slip_id
                layer.open({
                    type: 2, // 1-在content中写html代码， 2-在content中写src路径
                    area: ['80%', '90%'],
                    title: "销售单详情",
                    content: url,
                    // content: Config.this_url+'/purchase/requisition',
                })
            });
            $('#getcount').click(function () {
                var data = $('form').serialize();
                that = $(this)
                var url = Config.this_url+'/sales/slip/countget';
                $.post(url,data,function (res) {
                    that.find('#num').html(res.num)
                    that.find('#price').html(res.price)
                    that.find('#sfhj').html(res.sfhj)
                })
                setTimeout(function(){
                    layer.closeAll('loading');
                }, 2000);
            })
            $('.screen').click(function () {
                layer.open({
                    type: 2, // 1-在content中写html代码， 2-在content中写src路径
                    area: ['70%', '90%'],
                    title: "选择商品",
                    content: 'seach?house_id='+$('#c-storehouse_id').val(),
                })
            })
            // 为表格绑定事件
            Table.api.bindevent(table);
        },

    };
    return Controller;
});